//
//  InnerNewsCell.m
//  RSW.IOS
//
//  Created by zhaiqiuqiu on 17/1/16.
//  Copyright © 2017年 com.xtion.crm. All rights reserved.
//

#import "InnerNewsCell.h"

@interface InnerNewsCell()
{
    HeadImageView *_headImageView;
    UILabel *_titleLabel;
    UILabel *_contentLabel;
    UILabel *_dateLabel;
}
@end

@implementation InnerNewsCell

-(id)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    
    _headImageView = [[HeadImageView alloc]initWithFrame:CGRectMake(0,0, 70, 60)];
    _headImageView.headImage = [UIImage imageNamed:@"img_defaulthead.png"];
    [self.contentView addSubview:_headImageView];
    
    CGSize s = [NSString charSizeWithSystemFontSize:16];
    _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, s.width*10, s.height)];
    _titleLabel.backgroundColor = [UIColor clearColor];
    _titleLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:_titleLabel];
    
    s = [NSString charSizeWithSystemFontSize:13];
    _contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, s.width*10, s.height)];
    _contentLabel.backgroundColor = [UIColor clearColor];
    _contentLabel.font = [UIFont systemFontOfSize:13];
    _contentLabel.textColor = [UIColor colorWithHex:mcrmSAASUISkinColorTextStyle9b9b9bColor];
    [self.contentView addSubview:_contentLabel];
    
    s = [NSString charSizeWithSystemFontSize:10];
    _dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, s.width*20, s.height)];
    _dateLabel.backgroundColor = [UIColor clearColor];
    _dateLabel.font = [UIFont systemFontOfSize:10];
    _dateLabel.textColor = [UIColor grayColor];
    _dateLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_dateLabel];
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _headImageView.origin = CGPointMake(10, 0);
    _headImageView.centerY = self.contentView.height/2;
    
    _titleLabel.origin = CGPointMake(_headImageView.right + 10, _headImageView.top);
    _contentLabel.origin = CGPointMake(_headImageView.right + 10, _titleLabel.bottom + 3);
    
    _dateLabel.bottom = self.contentView.bottom;
    _dateLabel.right = self.contentView.right - 10;
}

-(void)setHeadImage:(UIImage *)headImage
{
    _headImageView.headImage = headImage;
}

-(void)setTitle:(NSString *)title
{
    _titleLabel.text = title;
}

-(void)setContent:(NSString *)content
{
    _contentLabel.text = content;
}

-(void)setCreateTime:(NSDate *)createTime
{
    _dateLabel.text =  [NSString stringWithFormat:@"日期：%@",[createTime toStringDate:NSDateFormatByyMdHm]];
}
@end
